************************* Use C-Pg Up to return *******************************
********************* Use Pg Up and Pg Dn to scroll ***************************
*************************** Use C-s to search *********************************
Copyright (C) 1993 Leon van Dommelen      There is no warranty on this software
Library letter: T (TEX.ED)

				   TeX

This file covers the TeX/LaTeX mode of Freemacs Mint II.


Topics:				Description
-------------------------------------------------------------------------------

About				Copyright, no warranty, history

Intro				Description of TeX mode

Getting Started			Setting options

Summary				Key summary
- Help				Interactive listing of TeX keys
- Setup				Setting up TeX mode
- Letters			Creating letters
- Block Closing			Finishing LaTeX \begin structures
- Quotes			Inserting left/right German/English quotes
- Enclose			By quotes, braces, $-signs, emphasize, index
- Highlight			The special characters
- Show Match			For $, $$, or }
- Abbreviations			For TeX commands
- Running [La]TeX		Pocessing the TeX file

Abbreviations			For TeX commands
- Setup				How to set up expansion of abbreviations
- Keys				That expand abbreviations
- Examples			Some examples of abbreviations

Letters				How to create them

Block Closing			Finishing LaTeX \begin structures

Running [La]TeX			From `inside' Emacs
- Intro				General description
- Setup				Essential
- Regions			Processing only part of a buffer

Problems			Some possible problems with TeX mode


				= About =
-------------------------------------------------------------------------------


TeX mode is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 1, or (at your option) any later version.

TeX mode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
TeX mode; if not, write to:

			The Free Software Foundation, Inc.
			Kendall Square
			Cambridge, MA 02130
			USA

Written by:

			Leon van Dommelen

See subject:		Contact			Contact Leon van Dommelen


History:
--------

Replaces a TeX mode written by:

			Thorsten Ohl, td12@ddagsi3.bitnet
			Copyright (C) 1989, 1990 by Thorsten Ohl

Thorsten Ohl derived his version from code by:

			Michael Hirsch, mhirsch@garnet.berkeley.edu
			Tim Hoverd, logcam!timh@uunet.UU.NET

12/20/92 Rewritten most code.
12/21/93 Upgraded to Freemacs Mint II
         TEX.HLP added


				= Intro =
-------------------------------------------------------------------------------


TeX mode is intended to simplify creating documents using TeX or LaTeX.

In his book `LaTeX', Leslie Lamport lists annoying errors which unnecesarily
lengthen the process of document development.  Here they are reproduced, along
with the ways TeX-mode helps you to combat them:

1. A misspelled command or environment name.

   Use the TeX-mode abbreviations.  If you misspell an abbreviation, it will
   either not expand, or expand to something different altogether. It is less
   and easier typing too.

2. Improperly matching braces.

   Use commands which insert braces as a pair:  TeX-mode abbreviations enter
   all corresponding required brackets and position the cursor at the right
   spot in between them.  Or, the key sequence C-c { will insert matching `{}'
   as a pair, enclosing an optional number of words around the cursor. Or, M-{
   will emphasize the word(s) at the cursor using matching `{\em' and `}'.
   Other commands such as M-Return also reduce the chances of improperly closed
   blocks.

   When you do enter brackets separately, TeX mode gives you various ways to
   verify that you are properly closing the blocks: When you insert `}', TeX
   mode will momentarily flash the cursor at the corresponding `{'.  If you
   double click the left mouse button on either bracket, all text to the
   matching bracket will be shown highlighted. If you press M-C-b beyond a `}'
   closing a block, the cursor will skip backward to the `{' starting the
   block. Similarly M-C-f skips forward to the end of the next block.

3. Trying to use one of the characters `#$%&_{}~^\' as a regular character.

   TeX-mode will briefly highlight these when you type them to indicate their
   special status, except when they are preceded by the required `\'. For `$'
   and `}', if a matching opening `$' or `$$', or `{' is found, it will be
   flashed instead.

4. Improperly matching formula delimiters, for example, a `\(' command without
   the matching `\)'

   Use commands which insert these as a pair. Instead of separately entering
   `\(' and `\)', C-c $ will insert a matching set of $-signs, enclosing an
   optional number of words.  Instead of using separate `\[' and `\]', the TeX
   abbreviation `bdm/' inserts `\begin{displaymath}' and `\end{displaymath}'
   lines and positions the cursor in between. Looks better, too.

   If you do use `\)' or `\]', the matching `\(' or `\[' will be flashed to
   show what block is being closed.  Instead of typing `\right', use the
   abbreviations `rt/': the `rt/' will insert `\right' and flash the
   corresponding `\left'

5. The use in ordinary text of a command like ^ that can appear only in a
   mathematical formula.

   Sorry, TeX-mode is unaware of the mode TeX will be in while processing it.

6. A missing `\end' command.

   Use TeX abbreviations.  Most abbreviations for `\begin{...}' will also
   insert the matching `\end{...}' statement and put the cursor in between,
   inserting a suitable line template.

   For abbreviations for constructs requiring finishing such as `btr' (for
   `\begin{tabular}{}'), press M-Return on finishing the line.  This will put
   in the `\end{tabular}' as well as put the `&  & ... \\' line template in
   between.

7. A missing command argument.

   Use TeX abbreviations.  The abbreviations show all required arguments as
   empty {}-brackets.  Some also show a list of allowed arguments.

If you do make errors, TeX mode will locate them for you, showing the error
message in a second window.


			    = Getting Started =
-------------------------------------------------------------------------------


Getting into TeX mode is easy: simply edit a file with a .TEX file extension.
If your TeX file has a different extension, you can use M-x TeX-mode to
enter it explicitly.

In TeX mode, F1 m shows a brief list of key definitions.

Now change the TeX defaults as needed using M-x TeX-set-options.


				= Summary =
-------------------------------------------------------------------------------


This topic summarizes the various keys defined by TeX Mode.


Help:
-----

C-c C-h			Sumarize the TeX key definitions.
See command:		TeX-help			Also: F1 m


Setup:
------

			Make the current buffer a TeX buffer
See command:		M-x TeX-mode			Also: M-x tex-mode
Note: this command is not needed if the file has the usual .TEX extension.

			Set the TeX mode defaults
See command:		M-x TeX-set-options

			Show the TeX mode settings
See command:		M-x TeX-show-options

C-\			Set plain or LaTeX mode
See command:		TeX-plain-mode

			Set German mode
See command:		M-x TeX-German-mode


Letters:
--------

C-c l			Create a letter
See command:		TeX-make-letter

			Add another letter
See command:		M-x TeX-add-letter

C-c C-l			Edit the default address and signature information
See command:		TeX-letter-header

See topic:		Letters


Block Closing:
--------------

M-Return		Close a LaTeX block, or insert another template
See command:		TeX-close-environment		Also: C-c C-f

See topic:		Block Closing


Quotes:
-------

'			Insert ` or ' as apropriate
See command:		TeX-insert-single-quote

"			Insert ``, ", "`, or "' as apropriate
See command:		TeX-insert-double-quote


Enclose:
--------

C-c "			Double quote word[s]
See command:		TeX-double-quote

C-c '			Single quote word[s]
See command:		TeX-single-quote

C-c $			Enclose word[s] with dollar signs
See command:		TeX-dollar

C-c {			Enclose word[s] with braces
See command:		TeX-insert-braces

M-{			Emphasize word[s]
See command:		TeX-emphasize

C-c i			Index word[s]
See command:		TeX-index-entry


Braces:
-------

M-C-b			Move back over matching { and }
See command:		TeX-backward-list

M-C-f			Move forward over matching { and }
See command:		TeX-forward-list


Highlight:
----------

\, &, %, #, ~, _, ^, {	Highlight briefly if not preceded by \
See command:		TeX-highlight


Show Match:
-----------

$			Show matching $ or $$ or highlight briefly
See command:		TeX-flash-$


}			Show matching { or highlight briefly
See command:		TeX-flash-}


Abbreviations:
--------------

/			Expand the abbreviation left or insert /
See command:		TeX-expand

C-c a			List the system defined abbreviations
See command:		TeX-list-abbrevs		Also: ?/

For additional info:
See topic:		Abbreviations


Running [La]TeX:
----------------

C-c C-b			Run [La]TeX on the entire buffer
See command:		TeX-buffer

C-c C-r			Run [La]TeX on the selected region
See command:		TeX-region

C-c C-c			Edit the default header for regions
See command:		TeX-edit-header

C-c C-v			View the result of C-c C-b or C-c C-r
See command:		TeX-preview

C-c C-p			Print the results of C-c C-b or C-c C-r
See command:		TeX-print

For additional info:
See topic:		Running [La]TeX


			     = Abbreviations =
-------------------------------------------------------------------------------

TeX mode allows you to type in abbreviations for standard TeX commands.
They are expanded to the full text when you press C-x ' or /


Setup:
------

Command M-x TeX-set-options allows you to turn off abbreviation expansion
when / is pressed by changing T-hot-slash.
See command:		TeX-set-options

To turn on automatic expansion of abbreviations whenever Space or Return
is pressed, use M-x Abbrev-mode.
See command:	Abbrev-mode


Keys:
-----

/			Expand the abbreviation immediately before the cursor
Unlike C-x ' and Space and Return in Abbrev mode, slash does not recognize
user-defined abbreviations.
?/			List all TeX abbreviations
See command:		TeX-expand

C-x '			Expand the previous abbreviation
User-defined abbreviations take precedence over system-defined ones.
See command:		expand-abbrev

Space or Return		Expand the previous abbreviation if in Abbrev mode
User-defined abbreviations take precedence over system-defined ones.
See command:		M-x Abbrev-mode


Examples:
---------

The abbreviations are different in plain and LaTeX modes.  Most abbreviations,
including the next two, are for LaTeX mode:

ac/	inserts `addtocounter{}{}', puts the cursor within the first set of
	brackets and list the most important counters on the prompt line

bey/	inserts `\begin{eqnarray}' and closes the block: it inserts
	`\end{eqnarray}', defines a `& & \\' template, inserts the template
	and positions the cursor appropriately.  If you hit M-Return, another
	template is inserted.

ltr/	creates a letter (either in plain and LaTeX mode). Before using this
	the first time, store your name and address using C-c C-l.

?/	lists the active abbreviations

Some `abbreviations' are mainly intended as a memory aid:

roman, caps, ital, bold, ... for the more cryptic \rm \sc \it \bf ...
o... abbreviations are document options
sp... abbreviations are the various blank spaces \, \; \: \!
sz... abbreviations are the various font sizes


				= Letters =
-------------------------------------------------------------------------------

This topic discusses how to use TeX mode to create letters.

To create a letter, edit a file of the desired name.  If this is your first
letter, you will need to enter your address and signature information
first: press C-c C-l and change the \address (LaTeX) or \senderaddress (plain)
to your current address, and change the \signature.
See command:		TeX-letter-header

After those defaults have been set, you can create a letter by simply
pressing C-c l.  This will put you at the place where you can enter the
addressee.
See command:		TeX-make-letter

The default letter format is stored in file LETTER.TEX or LETTERLA.TEX
and can be changed using C-c C-l. If you need more than one default letter
format, you can create additional files LETTER1.TEX, LETTER2.TEX, ... along
the same lines.  To use one of these alternate files, prefix the C-c l
sequence with a C-u prefix; for example C-u 1 C-c l creates a letter using
default file LETTER1.TEX.
See command:		TeX-make-letter

You can add more letters subsequently:
See command:		TeX-add-letter


			    = Block Closing =
-------------------------------------------------------------------------------

This topic discusses how TeX mode completes LaTeX \begin{...} structures.

Pressing C-c C-f or M-Return on a line containing a \begin{...} command will
create the \end{...} command line and puts the cursor on an indented line
in between the two. The indented line will contain the usual formatting
commands for that environment.

As an example, pressing M-Return anywhere in a \begin{itemize} line creates:

	\begin{itemize}
	    \item 
	\end{itemize}

The cursor will be at the end of the \item line, ready for typing in the
first item.  To start the second item, press M-Return again; a second
idented \item will be inserted.  The \item line is the template.

Note that the template will be overwritten when you close another \begin{..}
line with M-Return.

For an eqnarray environment, the template will have the tabbing characters
for the three columns.  For an array or tabular environment, TeX mode
looks at the number of alphabetic characters in the second argument to
decide the number of columns.  This does not work if you have additional
commands in the second argument.  In such cases you can explicitly
specify the number of columns in the template with a C-u prefix.  For
example, C-u 5 M-Return creates a 5 column template.  In the same way
you can specify the number of columns in the tabbing environment.

See command:		TeX-close-environment


			    = Running [La]TeX =
-------------------------------------------------------------------------------


This topic discusses running TeX without really leaving the editor.


Intro:
------

The way most of us use TeX is to create a document, save and exit the editor,
run TeX, write the error messages and location on a piece of scratch paper,
re-enter the editor and file, locate the errors, correct them, and
repeat the process.

Instead, ideally in Emacs you only press C-c C-b.  Then Emacs will run [German]
[La]TeX on the file, and puts the errors in a second window.  Next it displays
each error in turn when you press C-x C-n, and also locates it in the file,
allowing you to correct it.
See command:		TeX-buffer

If there are no errors, you can display the results using C-c C-v, or print
them with C-c C-p.
See command:		TeX-preview
See command:		TeX-print

The subtopic below discuss how to get things to work properly.


Setup:
------

Things may not be as ideal as described above in the introduction.
Unfortunately, TeX and TeX viewers need a lot of memory, and since Emacs stays
in memory, you cannot have much loaded before you get `Out of memory' messages.
If you are reading this, you may already have exceeded the limit.

Briefly, what you probably want to do is execute M-x TeX-set-options to clear
the TeX command shell.  In that case Emacs exits before running TeX, the viewer,
or printer.  However, before it exits, it creates a batch file; this file
allows you to proceed when returned to DOS by issuing a $-EMACS command.

Another thing you may need to change using M-x TeX-set-options are the commands
that Emacs uses to run TeX, and view or print the results.  If you have emTeX
or PC-TeX, the default DOS commands TEX, LATEX, V, and TEXPRINT may be
acceptable to run [La]TeX and view or print the results. Otherwise, change
these but do not provide a filename; Emacs itself provides the name of the
scratch file it uses to hold the buffer being processed. (That file is
$-T-TEMP.TEX in the Emacs directory).  You will also need to change file
TEXPRINT.BAT if you do not use DVIPS or a postscript printer on LPT1.

You can avoid the need to issue a $-EMACS command if you run Emacs using the
CEMACS command, and you also use M-x set-some-options to set the `Emacs recall
command' to C:\EMACS\CEMACS.BAT CONTINUED, changing the directory if necessary.

For more info:
See command:		TeX-set-options
See command:		set-some-options
See subject:		memory


Regions:
--------

If you are editing a sizable file, you may want to TeX a small part of it,
such as a table, separately.  Using C-c C-b you would have to wait while
TeX crunches through the entire document until it reaches the table or
whatever.

It would be much faster if you could just process the small part you are
working on.  TeX mode allows you to select a part of a document by setting
a mark at the start (using C-@ or the menu) and putting the cursor at the end.
To process the selected part, press C-c C-r.

There is an obvious difficulty though: by selecting only a small part
of the document, you probably lose most of the initializations: fonts,
documentstyle, dimensions, ...

To patch things up, TeX mode puts an header in front of the region you
selected.  The way it goes about selecting the header is:

1. First it looks in the buffer itself for an header.  In LaTeX mode, it
takes everything from the \documentstyle command to the \begin{document}.
In plain TeX mode, it takes everything in between the `%**start of header'
and `%**end of header' comment lines, if you have provided those.  (You
can insert those lines using abbreviations sh/ and eh/).

2. If TeX mode cannot find such a header in the buffer, it uses a file in
the emacs directory instead.  The file it uses is DFTEX.TEX or DFLATEX.TEX,
depending on the mode. You can edit those files first using C-c C-c to
put in your usual or current initializations.

See command:		TeX-region
See command:		TeX-edit-header


				= Problems =
-------------------------------------------------------------------------------


TeX mode expects a standard syntax table, like most of Freemacs Mint II.
Actually, it changes the syntax table slightly, making \ a word character.

If you find a bug in TeX mode, please drop me a note.
See subject:	Contact			How to contact me.


************************* Use C-Pg Up to return  ******************************
************************* Use Pg Up to scroll up ******************************
*******************************************************************************
